/* Android-Michi is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Android-Michi is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Android-Michi; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */


package com.chaski.michi;

import controller.Controller;

import android.os.Bundle;
import android.app.Activity; 
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.MenuItem; 

public class Michi extends Activity {


	Controller controller;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		controller = new Controller(this);
		controller.start();
		initialStartup();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_michi, menu);
		return true;
	}


	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case R.id.menu_resetart_2player:
			controller.restart();
			return true;

		case R.id.menu_resetart_1player:
			controller.restart1player();
			return true;   

		default:
			return super.onOptionsItemSelected(item);
		}
	}

	public void initialStartup() {
		AlertDialog.Builder adb = new AlertDialog.Builder(this);
		adb.setTitle(R.string.android_michi_string);
		adb.setMessage(R.string.number_of_players_string);
		adb.setPositiveButton(R.string.one_player_string, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				controller.restart1player();

			}
		});
		adb.setNegativeButton(R.string.two_player_string, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				controller.restart();
			}
		});
		adb.show();
	}
}
